package org.altervista.cp.microkernel.persistence.spi;

import java.sql.SQLException;

import javax.sql.DataSource;

import org.altervista.cp.microkernel.io.TemporaryFileGenerator;
import org.altervista.cp.microkernel.persistence.PersistenceException;
import org.altervista.cp.microkernel.persistence.PersistenceSession;
import org.altervista.cp.microkernel.persistence.PersistenceSessionFactory;

public class DefaultPersistenceSessionFactory implements
		PersistenceSessionFactory {

	public DefaultPersistenceSessionFactory(DataSource ds,
			TemporaryFileGenerator tfg) {
		_ds = ds;
		_tfg = tfg;
	}

	public PersistenceSession openSession() {
		try {
			return new DefaultPersistenceSession(_ds.getConnection());
		} catch (SQLException e) {
			throw new PersistenceException(e);
		}
	}

	private DataSource _ds;
	private TemporaryFileGenerator _tfg;

}
